<%- include('common/head.ejs') %>

<div id="draft">
    <div class="margin-left-20 margin-right-20">
        <button class="btn btn-danger" onclick="delMail('/draft')">删除草稿</button>
        <table class="table table-striped">
            <thead>
            <tr>
                <th class="col-sm-1">
                    <input type="checkbox" id="selectAll">
                </th>
                <th class="col-sm-1"><span class="glyphicon glyphicon-envelope"></span></th>
                <th class="col-sm-1">收件人</th>
                <th class="col-sm-7">主题</th>
                <th class="col-sm-2">时间</th>
            </tr>
            </thead>
            <tbody>
            <% mails.forEach(function(mail){ %>
            <tr>
                <td><input type="checkbox" name="checked" value="<%= mail._id %>"></td>
                <td><span class="glyphicon glyphicon-envelope"></span></td>
                <td><%= mail.toMail %></td>
                <td id="mouseMove" onclick="editMail('draft','<%= mail._id %>','<%= mail.toMail %>','<%= mail.title %>','<%= mail.text %>')"><%= mail.title%></td>
                <td><%= mail.updated_at%></td>
            </tr>
            <% }) %>
            </tbody>
        </table>
        <button class="btn btn-danger margin-top-20" onclick="delMail('/draft')">删除草稿</button>
       <div class="pull-right">

           <ul class="pager" >
               <span class="margin-right-20"><%= page + '/' + pageTotal %></span>
               <li class="<%= page == '1' ? 'hide' : null%>"><a href="/mail/draft?page=<%= JSON.parse(page) - 1%>">上一页</a></li>
               <li class="<%= page == pageTotal ? 'hide' : ''%>"><a href="/mail/draft?page=<%= JSON.parse(page) + 1%>">下一页</a></li>
               <li><input type="text" id="page" class="page"></li>
               <li><a href="JavaScript:getPageData('<%= pageTotal %>','draft')">跳转</a></li>
           </ul>
       </div>
    </div>
</div>

<div id="edit" class="hide">
    <div class="main-background">
        <form id="draftEdit" class="form-horizontal margin-left-20 margin-right-20">
            <div class="form-group">
                <div class="col-sm-offset-2">
                    <button type="button" class="btn btn-primary margin-right-20" onclick="mailManage('draftEdit','/mail/write','0')">发送</button>
                    <button type="button" class="btn btn-primary margin-right-20" onclick="mailManage('draftEdit','/mail/update','2')">存草稿</button>
                    <button type="button" class="btn btn-primary" onclick="changePage('draft')">关闭</button>
                </div>
                <input class="hide" id="mailId" name="mailId" />
                <input class="hide" id="state" name="state" />
            </div>
            <%- include('common/edit.ejs')%>
            <div class="form-group">
                <div class="col-sm-offset-2">
                    <button type="button" class="btn btn-primary margin-right-20" onclick="mailManage('draftEdit','/mail/write','0')">发送</button>
                    <button type="button" class="btn btn-primary margin-right-20" onclick="mailManage('draftEdit','/mail/update','2')">存草稿</button>
                    <button type="button" class="btn btn-primary" onclick="changePage('draft')">关闭</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript" src="/javascripts/draft.js" ></script>
<%- include('common/footer') %>